package pl.zuiol.games.poker.ui;

import java.util.List;

import pl.zuiol.games.poker.Player;
import pl.zuiol.games.poker.util.Card;
import pl.zuiol.games.poker.util.GameStage;
import pl.zuiol.games.poker.util.Hand;
import pl.zuiol.games.poker.util.Util;

/**
 * User: Damian
 * Date: 24.08.11
 * Time: 22:25
 */
public class GameTable {

    public void showWelcome(){

        Util.writeln("***********************************************");
        Util.writeln("**************** IMDG POKER *******************");
        Util.writeln("************* BY DAMIAN PEZDA *****************");
        Util.writeln("***********************************************");
    }

    public void showPot(){

    }

    public void showFloop(List<Card> floopCards){

        Util.write("Floop: " );
        for(Card card : floopCards){
            Util.write(card.toString()  + "|");
        }

    }

    public void showTurn(List<Card> turnCards){

        Util.write("Turn: " );
        for(Card card : turnCards){
            Util.write(card.toString()  + "|");
        }

    }

    public void showRiver(List<Card> riverCards){

        Util.write("Floop: " );
        for(Card card : riverCards){
            Util.write(card.toString()  + "|");
        }

    }

    public void showNewGame(){

        Util.writeln("===========================================");
        Util.writeln("============ NOWE ROZDANIE ================");
        Util.writeln("===========================================");

    }

    public void showPlayerCards(Hand hand){

        Util.writeln("My cards: " + hand.toString());

    }

    public void showPlayerDetails(Player player){

        Util.writeln(player.getName() + "");
        //Util.writeln("Cards in hand: " + player.getHand().toString());
        Util.writeln("Money: " + player.getPurse() + "$");

    }

    public int showCheckOption(int money){

        Util.writeln("Possible actions: ");
        Util.writeln("1. Check " + money + " |2. Rise | 3. Fold");
        int result = Integer.parseInt(Util.getText());
        System.out.println("Resultat : " + result);

        switch(result){
            case 1 : {
                return 0;
            }
            case 2 : {
                Util.writeln("How much would you like to bet?");
                return Integer.parseInt(Util.getText());
            }
            case 3 : {
                return  -1;
            }
            default :{
            	System.out.println("Nie odpowiedziales prawidolowo, ponawiam pytanie:");
                return showCheckOption(money);
            }
        }

    }

    public int showBetOption(){
        Util.writeln("Possible actions: ");
        Util.writeln("1. Bet |2. Check|3. Fold ");
        int result = Integer.parseInt(Util.getText());

        switch(result){
            case 1 : {

                Util.writeln("How much would you like to bet?");
                return Integer.parseInt(Util.getText());
            }
            case 2 : {
                return 0;
            }
            case 3 : {
                return -1;
            }
            default : {

                return showBetOption();

            }
        }
    }
    
    public void showCurrentGameStage(GameStage gameStage){
    	Util.writeln("========================================================");
    	Util.writeln("========= " + gameStage.toString() + "==================");
    	Util.writeln("========================================================");
    }


}
